﻿using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
using System.Collections;

namespace BehaviorSystem
{
    /// <summary>
    /// 等待节点
    /// </summary>
    public class WaitNode : ActionNode
    {
        public float WaitTime { get; private set; }
        public float curTime = 0;

        public WaitNode(IBehaviorAgent agent, float waitTime) : base(agent)
        {
            curTime = 0;
            WaitTime = waitTime;
        }

        public override BTNodeState HandleAction()
        {
            HandleWait();
            return CurState;
        }

        public override void ResetNode()
        {
            CurState = BTNodeState.Running;
            curTime = 0;
        }

        void HandleWait()
        {
            if (CurState == BTNodeState.Running)
            {
                curTime += Time.deltaTime;
                if (curTime > WaitTime)
                {
                    CurState = BTNodeState.Success;
                    Debug.Log(System.DateTime.Now);
                }
            }
        }
    }
}